import java.util.ArrayList;
import java.util.List;

public class Solution784 {
    public List<String> letterCasePermutation(String s) {
        List<String> ans=new ArrayList<>();
        dfs(s,0,new StringBuilder(),ans);
        return ans;
    }

    private void dfs(String s, int k, StringBuilder stringBuilder, List<String> ans) {
        if (k==s.length()){
            ans.add(stringBuilder.toString());
            return;
        }
        if (s.charAt(k)>='0' && s.charAt(k)<='9'){
            stringBuilder.append(s.charAt(k));
            dfs(s,k+1,stringBuilder,ans);
            stringBuilder.deleteCharAt(stringBuilder.length()-1);
        }else{
            stringBuilder.append(String.valueOf(s.charAt(k)).toLowerCase());
            dfs(s,k+1,stringBuilder,ans);
            stringBuilder.deleteCharAt(stringBuilder.length()-1);
            stringBuilder.append(String.valueOf(s.charAt(k)).toUpperCase());
            dfs(s,k+1,stringBuilder,ans);
            stringBuilder.deleteCharAt(stringBuilder.length()-1);
        }
    }

    public static void main(String[] args) {
        System.out.println(new Solution784().letterCasePermutation("a1b2"));
    }
}
